package cn.itcast.user.service;

import cn.itcast.user.mapper.UserMapper;
import cn.itcast.user.pojo.User;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService {

    @Autowired
    private UserMapper userMapper;

    public User queryById(Long id) {
        return userMapper.findById(id);
    }

    public String save(User user) {
        int insert = userMapper.insert(user);
        return  insert > 0  ? "新增成功" : "新增失败";
    }

    public void delUser(Long id) {
        userMapper.deleteById(id);
        System.out.println("删除成功");
    }

    public void putUser(User user) {
        userMapper.updateById(user);
    }
}